<?php

/**
 * User form base class.
 *
 * @method User getObject() Returns the current form's model object
 *
 * @package    Serag
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'user_code_num'       => new sfWidgetFormInputHidden(),
      'first_name'          => new sfWidgetFormInputText(),
      'middle_name'         => new sfWidgetFormInputText(),
      'last_name'           => new sfWidgetFormInputText(),
      'username'            => new sfWidgetFormInputText(),
      'address1'            => new sfWidgetFormInputText(),
      'email'               => new sfWidgetFormInputText(),
      'password'            => new sfWidgetFormInputText(),
      'active'              => new sfWidgetFormInputText(),
      'deleted'             => new sfWidgetFormInputText(),
      'birth_date'          => new sfWidgetFormDate(),
      'city'                => new sfWidgetFormInputText(),
      'phone'               => new sfWidgetFormInputText(),
      'user_account_number' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Account'), 'add_empty' => true)),
      'is_main_user'        => new sfWidgetFormInputText(),
      'is_admin'            => new sfWidgetFormInputText(),
      'title_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Title'), 'add_empty' => true)),
      'is_visible'          => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'user_code_num'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('user_code_num')), 'empty_value' => $this->getObject()->get('user_code_num'), 'required' => false)),
      'first_name'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'middle_name'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'last_name'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'username'            => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'address1'            => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'email'               => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'password'            => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'active'              => new sfValidatorInteger(array('required' => false)),
      'deleted'             => new sfValidatorInteger(array('required' => false)),
      'birth_date'          => new sfValidatorDate(array('required' => false)),
      'city'                => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'phone'               => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'user_account_number' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Account'), 'required' => false)),
      'is_main_user'        => new sfValidatorInteger(array('required' => false)),
      'is_admin'            => new sfValidatorInteger(array('required' => false)),
      'title_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Title'), 'required' => false)),
      'is_visible'          => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'User';
  }

}
